package org.interfaceadaptation.test.notnull;

import java.util.Arrays;
import java.util.Collection;

public class CompoundInstrospectorRegister {

	private static CompoundInstrospectorRegister compoundInstrospectorRegister = new CompoundInstrospectorRegister();

	private Collection<CompoundInstrospector> registeredCompoundInstrospectors = Arrays
			.asList((CompoundInstrospector) new ArrayCompoundInstrospector());

	public static CompoundInstrospectorRegister getInstance() {
		return compoundInstrospectorRegister;
	}

	protected CompoundInstrospectorRegister() {
	}

	public CompoundInstrospector getCompoundInstrospectorFor(Object element) {
		for (CompoundInstrospector compoundInstrospector : registeredCompoundInstrospectors) {
			if (compoundInstrospector.isCompoundInstrospectorFor(element)) {
				return compoundInstrospector;
			}
		}
		return null;
	}
	
	protected void setRegisteredCompoundInstrospectors(Collection<CompoundInstrospector> registeredCompoundInstrospectors) {
		this.registeredCompoundInstrospectors = registeredCompoundInstrospectors;
	}

}
